'''
multiprocessing模块就是跨平台版本的多进程模块。


'''

# https://www.cnblogs.com/kaituorensheng/p/4445418.html

import multiprocessing
import time
import os

def worker_1(interval, arg1=0):
    print ("worker_1")
    time.sleep(interval)
    print(arg1)
    print ("end worker_1")

def worker_2(interval):
    print ("worker_2")
    time.sleep(interval)
    print ("end worker_2")

def worker_3(interval):
    print ("worker_3")
    time.sleep(interval)
    print ("end worker_3")

if __name__ == "__main__":
    p1 = multiprocessing.Process(target = worker_1, args = (1,111))
    p2 = multiprocessing.Process(target = worker_2, args = (1,))
    p3 = multiprocessing.Process(target = worker_3, args = (1,))

    p1.start()
    p2.start()
    p3.start()

    print("The number of CPU is:" + str(multiprocessing.cpu_count()))
    print('Parent process: %s.' % os.getpid())
    
    for p in multiprocessing.active_children():
        print("child   p.name:" + p.name + "\tp.id:" + str(p.pid))
    print ("END!!!!!!!!!!!!!!!!!")